home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk62 / pipe203 / read1006.c < prev   
C/C++ Source or Header  |  1995-03-19  |  784b  |  41 lines

  1.  
  2. /*
  3.  *  READ1006.C
  4.  *
  5.  *  READ1006 name
  6.  *
  7.  *  Open file with modes 1006 and read from it until EOF.  Used    to show
  8.  *  how    reading    from the MASTER    side of    a PIPE with the    SLAVE side connected
  9.  *  to a NEWCLI    works.
  10.  */
  11.  
  12. extern long Open(), Read();
  13.  
  14. #define    NULL 0L
  15.  
  16. main(ac, av)
  17. char *av[];
  18. {
  19.     char buf[256];
  20.     long fh;
  21.     long n;
  22.  
  23.     disablebreak();
  24.     if (av[1] == NULL) {
  25.     puts ("filename required... usually PIPE:a/tq");
  26.     puts ("Warning: you should have another CLI around");
  27.     puts ("in case you get caught so you can recover.");
  28.     exit(1);
  29.     }
  30.  
  31.     fh = Open(av[1], 1006);
  32.     if (fh == NULL) {
  33.     puts ("Unable to open file or SLAVE part of pipe not active");
  34.     exit(1);
  35.     }
  36.     while ((n =    Read(fh, buf, 256)) > 0)
  37.     write(1, buf, n);
  38.     Close(fh);
  39.     puts("Done");
  40. }
  41.